
<%

Function save_new_password (lng_k_email_inquiry, str_User_id, str_new_password)

'Info
'save_new_password = 1'= OK
'save_new_password = 0'= error
'call showMessage("1 " & lng_k_email_inquiry & ", 2 " & str_User_id & ", 3 " & str_new_password)
Dim i_error
Dim i_error_code
Dim intPos
Dim i_len'die länge des neuen pw
Dim i_len_ses_pw'default länge
Dim str_logfree'A1 >> nein - A0 >> ok

i_error = 0

'#1 überprüft ob ein leerzeichen im pw ist
intPos = 0'default
intPos = InStr(str_new_password," ")
if intPos > 0 Then
	i_error = 1
    i_error_code = 2
end if

i_len = Len(str_new_password)
i_len_ses_pw = Session("ses_pw_len")
If i_len < i_len_ses_pw Then
	i_error = i_error + 1
    i_error_code = 3
end if

'******************************************************************************
' überprüft ob die zugangsdaten (userid und pw) eindeutig sind
' InputParameter:
' i_check ... 0 >> es wird nur überprüft ob die user id eindeutig ist / 1 >> user id und pw müssen zusammen eindeutig sein
' str_User_id ... die eingegebene user id
' str_pw ... das eingegebene passwort
' lng_k_User_ID ... der aktuelle user
' i_info ... ob es eine neuanlage ist (0) oder schon ein bestehender user ist (1)
'******************************************************************************
'ob userid und pw ok sind - A1 >> nein - A0 >> ok
'Function fc_str_check_logindata(i_check, str_User_id, str_pw, lng_k_User_ID, i_info)
Dim lng_k_User_ID
Dim sql_lpw
Dim rs_lpw
Dim i_count
'(lng_k_email_inquiry, str_User_id, str_new_password)

lng_k_User_ID = 0 'default
sql_lpw ="SELECT tbl_0903_pw_inquiry.lng_fk_User_ID FROM tbl_0903_pw_inquiry " & _
"WHERE tbl_0903_pw_inquiry.lng_k_email_inquiry='" & lng_k_email_inquiry & "' " & _
"AND tbl_0903_pw_inquiry.str_User_id='" & str_User_id & "'"

'Response.Write(sql_lpw)
'response.End()

Set rs_lpw = Server.CreateObject("ADODB.RecordSet")
rs_lpw.Open sql_lpw, objConn, adOpenStatic, adLockReadOnly  
If Not rs_lpw.EOF Then
	lng_k_User_ID = rs_lpw.Fields("lng_fk_User_ID").Value
end if

rs_lpw.Close 
set rs_lpw = Nothing
'Response.Write(i_error)
str_logfree = fc_str_check_logindata(0, str_User_id, str_new_password, lng_k_User_ID, 1)
If str_logfree = "A1" Then' A1 >> nein - A0 >> ok
	i_error = i_error + 1
    i_error_code = 4
end if

'Response.Write(str_logfree)
'response.End()


'save new pw >> falls noch kein fehler war
If Cint(i_error) = 0 Then'=OK
	sql_lpw = "UPDATE tbl_0501_user SET " & _
	"str_User_id= '" & str_User_id & "'" & _
	", str_pw = '" & str_new_password & "'" & _
	" WHERE lng_k_User_ID = '"  & lng_k_User_ID & "'"

'Response.Write(sql_lpw) 
'Response.End()
  
	objConn.Execute sql_lpw
	
'check ob auch gespeichert wurde
	i_count = 0 'default
	sql_lpw = "SELECT COUNT(1) AS i_count FROM tbl_0501_user WHERE str_User_id ='" & str_User_id & "' AND str_pw ='" & str_new_password & "'"
	Set rs_lpw = Server.CreateObject("ADODB.Recordset")
	rs_lpw.Open sql_lpw, objConn, adOpenStatic, adLockReadOnly   
		i_count = rs_lpw.Fields("i_count")
		
'Response.Write(sql_lpw) 
'Response.End()
	
	rs_lpw.Close
	set rs_lpw = nothing
	
	If Cint(i_count) = 0 Then'no match
'		i_error = i_error + 1
'       i_error_code = 5
	end if

'speichert jetzt das neue pw in der <tbl_0903_pw_inquiry> ab
	sql_lpw = "UPDATE tbl_0903_pw_inquiry SET " & _
	"str_pw_new = '" & str_new_password & "', " & _
	"dt_timestamp_3 = '" & fc_str_date_server_format(Now(), 4) & "' " &_
	"WHERE tbl_0903_pw_inquiry.lng_k_email_inquiry='" & lng_k_email_inquiry & "' " & _
	"AND tbl_0903_pw_inquiry.str_User_id='" & str_User_id & "'"

'Response.Write(sql_lpw) 
'Response.End()
  
	objConn.Execute sql_lpw
	
end if''save new pw >> falls noch kein fehler war

'-----------------------------------------------------------
If Cint(i_error) = 0 Then
	save_new_password = 1'=OK
else
	save_new_password = i_error_code'=Error
end if

'call showMessage("save_new_password: " & save_new_password)

End Function

%>